import { SlateElement } from '@wangeditor/editor';
import {TagElement} from "./types";

/**
 * @description 把tag元素转换为 HTML
 * @param elem
 * @param childrenHtml
 * @returns tag元素的HTML字符串
 */
function tagToHtml(elem: SlateElement, childrenHtml: string): string {
  const {value, className} = elem as TagElement;
  const html = `<span 
        data-w-e-type="tag"
        data-w-e-is-void
        data-w-e-is-inline
        data-value="${value}"
        data-class-name="${className || ''}"
        class="${className || ''}"
        >${value}</span>`;
  return html;
}

const elemToHtml = {
  type: "tag",
  elemToHtml: tagToHtml
};

export default elemToHtml;
